package com.example.project.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.project.dto.vo.admin.AdminRoleVO;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Transient;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@Data
@Entity
@TableName("tb_user")
public class User {
    @Id
    @TableId(type = IdType.AUTO)
  private Long id;
  private String userName;
  private String password;
  private String avatar;
  private String email;
  private Integer state;
  private String regIp;
  private String loginIp;
  private LocalDateTime createTime;
  private LocalDateTime updateTime;
  private String salt;
  private String phone;
  private String school;
  private String gender;
  private String birthday;
//  @Transient
//  private List<AdminRoleVO> roles;
  // 1. 添加与 JPQL 匹配的构造方法（参数顺序、类型必须完全一致）
  public User(Long id, String userName, String avatar, String email,
              Integer state, LocalDateTime createTime, LocalDateTime updateTime) {
    this.id = id;
    this.userName = userName;
    this.avatar = avatar;
    this.email = email;
    this.state = state;
    this.createTime = createTime;
    this.updateTime = updateTime;
  }

  // 2. 必须保留无参构造（JPA 要求）
  public User() {
  }
}
